package train48days;

import java.util.Scanner;
import java.util.Stack;

public class 倒置字符串 {
    public static void main(String[] args){
        //每次读入一个字符串,以" "分隔,
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNext()){
            String str= scanner.nextLine();
            String[] arr=str.split(" ");
            //利用栈先进后出的特性
            Stack<String> stack=new Stack<>();
            //将字符串数组加入到栈
            for (int i = 0; i < arr.length; i++) {
                stack.push(arr[i]);
            }
            StringBuilder str1=new StringBuilder();
            while (!stack.isEmpty()){
                    //StringBuilder进行字符串拼接
                    str1.append(stack.pop() + " ");
            }
            System.out.print(str1);
        }
    }
}
